Skip to content

Add Web PubSub Chat service client - #48882

Open
yzt (Y-Sindo) wants to merge 13 commits into
Azure:mainfrom
Y-Sindo:azure-sdk-for-python-chat-serviceclient
Open

yzt (Y-Sindo) wants to merge 13 commits into
Azure:mainfrom
Y-Sindo:azure-sdk-for-python-chat-serviceclient

Conversation

@Y-Sindo

Copy link
Copy Markdown
Member

Description

Add an initial version of Web PubSub Chat service client.

Generated from Spec

  1. Initial Spec PR: Add Web PubSub Chat project azure-rest-api-specs#41187
  2. Follow-up Spec PR to correct spec in main branch (in-progress): Fix Web PubSub Chat spec azure-rest-api-specs#44881

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The new authentication client has blocking package-coexistence, credential-exposure, live-test, and spec-reproducibility issues.

Pull request overview

Adds the initial preview of the Azure Web PubSub Chat service client, including authentication, synchronous/asynchronous APIs, documentation, samples, and live-test infrastructure.

Changes:

  • Adds generated Chat service clients, models, paging operations, and custom token authentication.
  • Adds packaging metadata, API snapshots, documentation, and samples.
  • Adds unit/live tests, test resources, and CI registration.
File summaries
File Description
.chronus/changes/webpubsub-chat-customization-2026-08-17.md Records the feature addition.
eng/ignore-links.txt Excludes pre-publication links.
sdk/webpubsub/ci.yml Registers the package artifact.
sdk/webpubsub/tests.yml Uses explicit package selection.
sdk/webpubsub/azure-messaging-webpubsubchatservice/CHANGELOG.md Documents the preview release.
sdk/webpubsub/azure-messaging-webpubsubchatservice/LICENSE Adds licensing terms.
sdk/webpubsub/azure-messaging-webpubsubchatservice/MANIFEST.in Configures source distribution contents.
sdk/webpubsub/azure-messaging-webpubsubchatservice/README.md Documents setup and usage.
sdk/webpubsub/azure-messaging-webpubsubchatservice/_metadata.json Records the service API version.
sdk/webpubsub/azure-messaging-webpubsubchatservice/api.md Captures the public API surface.
sdk/webpubsub/azure-messaging-webpubsubchatservice/api.metadata.yml Records API snapshot metadata.
sdk/webpubsub/azure-messaging-webpubsubchatservice/apiview-properties.json Maps cross-language API definitions.
sdk/webpubsub/azure-messaging-webpubsubchatservice/assets.json References test assets.
sdk/webpubsub/azure-messaging-webpubsubchatservice/dev_requirements.txt Adds development dependencies.
sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json Adds npm lock metadata.
sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml Defines package metadata and dependencies.
sdk/webpubsub/azure-messaging-webpubsubchatservice/setup.py Adds setuptools packaging support.
sdk/webpubsub/azure-messaging-webpubsubchatservice/test-resources.bicep Provisions live-test resources.
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests.yml Defines package live-test CI.
sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml Pins the generating specification.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/__init__.py Declares the Azure namespace.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/__init__.py Declares the messaging namespace.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/__init__.py Adds the parent package initializer.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/__init__.py Exports the synchronous client.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_client.py Implements the generated sync client.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_configuration.py Configures sync policies.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_constants.py Defines built-in Chat roles.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_operations/__init__.py Initializes sync operations.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_operations/_operations.py Implements sync REST operations.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_operations/_patch.py Provides operation customization hooks.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_patch.py Customizes sync authentication and tokens.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_shared.py Adds shared authentication helpers.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_utils/__init__.py Initializes generated utilities.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_utils/model_base.py Supports generated models.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_utils/serialization.py Supports wire serialization.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_utils/utils.py Handles conditional request headers.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_version.py Defines version 1.0.0b1.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/__init__.py Exports the asynchronous client.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_client.py Implements the generated async client.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_configuration.py Configures async policies.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_operations/__init__.py Initializes async operations.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_operations/_operations.py Implements async REST operations.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_operations/_patch.py Provides async operation hooks.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_patch.py Customizes async authentication and tokens.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/models/__init__.py Exports generated models.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/models/_enums.py Defines permissions and user kinds.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/models/_models.py Defines Chat resource models.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/models/_patch.py Provides model customization hooks.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/py.typed Marks typed package support.
sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/types.py Defines JSON-compatible typed dictionaries.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/conftest.py Configures generated tests.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/testpreparer.py Prepares generated sync tests.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/testpreparer_async.py Prepares generated async tests.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service.py Adds generated sync operation tests.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_tests/test_web_pub_sub_chat_service_async.py Adds generated async operation tests.
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/chat_message_seed.py Seeds messages through WebSockets.
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/conftest.py Configures test proxy behavior.
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_chat_message_seed.py Tests WebSocket seeding helpers.
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client.py Tests synchronous custom behavior.
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_client_async.py Tests asynchronous custom behavior.
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py Exercises synchronous service workflows.
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py Exercises asynchronous service workflows.
sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/testcase.py Provides shared live-test helpers.
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_authentication.py Demonstrates authentication options.
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access.py Demonstrates sync client credentials.
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py Demonstrates async client credentials.
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_history.py Demonstrates sync message history.
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_history_async.py Demonstrates async message history.
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_message_management.py Demonstrates message updates and deletion.
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions.py Demonstrates sync resource management.
sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_roles_and_permissions_async.py Demonstrates async resource management.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/create_or_replace_role.py Generated role creation sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/create_or_replace_room.py Generated room creation sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/create_or_replace_room_member.py Generated membership creation sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/create_or_replace_user.py Generated user creation sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/delete_message.py Generated message deletion sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/delete_role.py Generated role deletion sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/delete_room.py Generated room deletion sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/delete_room_member.py Generated membership deletion sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/delete_user.py Generated user deletion sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/get_conversation.py Generated conversation retrieval sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/get_role.py Generated role retrieval sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/get_room.py Generated room retrieval sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/get_user.py Generated user retrieval sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/list_messages.py Generated message listing sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/list_roles.py Generated role listing sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/list_room_members.py Generated membership listing sample.
sdk/webpubsub/azure-messaging-webpubsubchatservice/generated_samples/chat/update_message.py Generated message update sample.
Review details

Files not reviewed (1)

  • sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
  • Files reviewed: 86/88 changed files
  • Comments generated: 5
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py Outdated
Comment thread sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml Outdated
Copilot AI review requested due to automatic review settings September 3, 2026 13:32
@Y-Sindo
yzt (Y-Sindo) force-pushed the azure-sdk-for-python-chat-serviceclient branch from 060288d to 6d547e2 Compare September 3, 2026 13:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Namespace compatibility, test configuration, typing, and resource-security defects must be resolved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Files not reviewed (1)

  • sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
  • Files reviewed: 86/88 changed files
  • Comments generated: 6
  • Review effort level: Balanced

Comment thread sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py Outdated
Comment thread sdk/webpubsub/tests.yml
default:
- azure-mgmt-webpubsub
- azure-messaging-webpubsubservice
- azure-messaging-webpubsubclient
Copilot AI review requested due to automatic review settings September 3, 2026 14:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The generation pin does not reproduce the submitted API, and safe-secret live runs skip Entra token coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Files not reviewed (1)

  • sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file

Suppressed comments (2)

sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live_async.py:304

  • Safe-secret runs disable local authentication, but the Entra-backed token request remains valid and should still be exercised. The early skip currently removes the only live coverage for that path; create and assert the key client only when local auth is enabled.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/tsp-location.yaml:2
  • The pinned source commit predates the linked correction PR, but this generated surface already includes corrections from that PR (for example, ChatPermission, which #44881 adds to models.tsp). Regenerating from this file will therefore produce a different API and discard those corrections. Please update the pin to the merged correction commit and regenerate before merging this SDK.
  • Files reviewed: 89/91 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread sdk/webpubsub/azure-messaging-webpubsubchatservice/tests/test_live.py Outdated
Copilot AI review requested due to automatic review settings September 3, 2026 14:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Client input validation is inconsistent and the JWT helper has an incorrect type annotation.

Review details

Files not reviewed (1)

  • sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file

Suppressed comments (3)

Previously missed (2) — in code that hasn't changed since the last review.

sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_patch.py:116

  • This slices the endpoint as though it is always HTTP(S), so values such as example.com or ftp://... produce malformed WebSocket URLs instead of rejecting the documented-invalid endpoint. minutes_to_expire is also validated only in the key-credential branch; token credentials send non-positive values to the service. Validate both inputs before branching so both authentication modes behave consistently.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_patch.py:113
  • This async path has the same input inconsistency as the sync client: slicing assumes an HTTP(S) endpoint and silently creates a malformed WebSocket URL for any other scheme, while non-positive expiration is rejected only for key credentials. Validate both values before selecting the authentication path.

sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_shared.py:62

  • on_request passes request.http_request.url here, which is a string, not an AzureKeyCredential. The incorrect annotation misdocuments the helper and causes static type checkers to flag the call.
    def _encode(self, url: AzureKeyCredential) -> str:
  • Files reviewed: 89/91 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI review requested due to automatic review settings September 3, 2026 15:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Endpoint validation, split-package compatibility, and an incorrect type contract must be addressed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Files not reviewed (1)

  • sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file

Suppressed comments (3)

Previously missed (2) — in code that hasn't changed since the last review.

sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_patch.py:118

  • endpoint[4:] assumes an HTTP(S) prefix. Inputs such as myservice.webpubsub.azure.com or another scheme therefore return a malformed WebSocket URL instead of the validation error provided by the existing Web PubSub client. Reject unsupported schemes before slicing the endpoint.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/aio/_patch.py:115
  • The async path has the same unchecked endpoint[4:] assumption as the sync client, so a non-HTTP(S) endpoint produces an invalid access URL. Validate the scheme before deriving the WebSocket URL.

sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubservice/chat/_shared.py:62

  • _encode receives request.http_request.url and uses it as the JWT audience, so this parameter is a string rather than an AzureKeyCredential. The current annotation gives static analysis and maintainers an incorrect contract.
    def _encode(self, url: AzureKeyCredential) -> str:
  • Files reviewed: 90/92 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml

@Y-Sindo yzt (Y-Sindo) left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found two issues in the current revision.

Comment thread sdk/webpubsub/azure-messaging-webpubsubchatservice/pyproject.toml

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The nested package is incompatible with the currently published parent distribution, and both clients can generate malformed access URLs from unsupported endpoint schemes.

Get a fresh assessment by requesting another Copilot review.

Review details

Files not reviewed (1)

  • sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file

Suppressed comments (1)

sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/init.py:12

  • This namespace fix does not make the new package compatible with the already-published azure-messaging-webpubsubservice 1.3.0: that version's regular azure.messaging.webpubsubservice package does not extend its path, so it hides the sibling chat directory and import azure.messaging.webpubsubservice.chat fails. The PR also leaves that distribution at version 1.3.0, so this fix cannot be published as-is. Please either move Chat out of another distribution's concrete package or version/release this parent-package change and require that new version from the Chat package.
  • Files reviewed: 90/92 changed files
  • Comments generated: 2
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.

Copilot AI review requested due to automatic review settings September 15, 2026 11:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The service-wide test pipeline omits the new package, so its live tests are not scheduled.

Get a fresh assessment by requesting another Copilot review.

Review details

Files not reviewed (1)

  • sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file
  • Files reviewed: 88/90 changed files
  • Comments generated: 1
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.

Comment thread sdk/webpubsub/tests.yml
Copilot AI review requested due to automatic review settings September 15, 2026 12:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Public request types require server-owned fields, expiration validation is credential-dependent, and samples log bearer-token URLs.

Review details

Files not reviewed (1)

  • sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file

Suppressed comments (9)

Previously missed (5) — in code that hasn't changed since the last review.

sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_patch.py:121

  • Validate the documented lower bound before branching on credential type. get_token_by_key currently raises for values below 1, but token-credential clients skip that helper and send the invalid value to the service, so the same public method has credential-dependent validation and exception behavior.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_patch.py:118
  • Validate the expiration before selecting the authentication path. As written, key credentials reject values below 1 locally while async token-credential clients issue a request with the invalid value, producing inconsistent behavior from this public method.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:33
  • ChatMessage is accepted as a request-body dictionary, but this type requires the server-generated id (and also createdAt/etag). Type checkers therefore reject valid create/update payloads that contain only writable fields. Regenerate a request shape that requires only writable properties.

This issue also appears in the following locations of the same file:

  • line 58
  • line 80
  • line 101
  • line 124
    sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access.py:19
  • This prints a bearer access token to stdout, where CI logs, terminals, or redirected output can retain it. It also contradicts the README warning not to log the returned URL. Remove the print, pass the URL directly to the intended client, and regenerate the README snippet from this sample.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/samples/sample_client_access_async.py:23
  • Avoid printing the connection URL because it embeds a bearer token and can be retained in terminal or CI logs. Pass it directly to the intended client instead, consistent with the package's README security guidance.

sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:58

  • This request dictionary requires the role name, even though the name is supplied separately as the operation's path parameter; it also requires the response-only ETag below. This makes the dictionary overload reject the valid permissions-only request body. Generate a role request shape containing only writable body fields.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:80
  • The room ID is supplied as a path parameter and returned by the service, but this request-body dictionary marks it required; defaultConversation and etag are likewise response-only. This causes type checkers to reject the valid title-only room body. Generate a request type containing only writable fields.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:101
  • The member's user ID is already supplied in the request path, but this body dictionary requires it and also requires the response ETag. The valid role-name-only request body is therefore rejected by type checkers. Generate a request type containing only writable body fields.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:124
  • The user ID is supplied as the operation's path parameter, but this body dictionary requires it and the response-only ETag. As a result, type checkers reject the same valid request shape accepted by HumanChatUser(...). Generate a request type that excludes server-owned fields.
  • Files reviewed: 88/90 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.

Copilot AI review requested due to automatic review settings September 15, 2026 13:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Public request TypedDicts incorrectly require server-generated fields, causing valid documented payloads to fail static type checking.

Review details

Files not reviewed (1)

  • sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file

Suppressed comments (5)

Previously missed (1) — in code that hasn't changed since the last review.

sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:33

  • ChatMessage is accepted by the update_message dictionary overload, but this Required marks the server-generated message ID as mandatory (and createdAt/etag below are likewise mandatory). Type checkers will therefore reject the supported payload shown in generated_samples/update_message.py, which supplies only createdBy and content. Model these response-only properties as optional in the input shape, or introduce a separate input type, then regenerate.

This issue also appears in the following locations of the same file:

  • line 58
  • line 80
  • line 101
  • line 124

sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:58

  • The dictionary overload for create_or_replace_role accepts ChatRole, but this makes the role name mandatory in the body even though it is supplied as the role_name path parameter; etag is also response-only. Consequently the generated {"permissions": ...} sample is rejected by static type checking. Separate the request shape from the response shape (or correct property visibility) and regenerate.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:80
  • create_or_replace_room documents and generates a title-only dictionary request, but this ChatRoom TypedDict requires the server-populated id, defaultConversation, and etag fields. This makes the generated sample invalid under mypy/pyright. Keep only title required for the request shape and regenerate the public types/API snapshot.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:101
  • The create_or_replace_room_member dictionary overload receives room_id and user_id as path parameters, yet this input TypedDict requires userId in the body and also requires the response-only etag. The generated sample correctly sends only roleName, so static type checking rejects a valid request. Define a request shape with only roleName required and regenerate.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:124
  • HumanChatUser is used as the dictionary request shape for create_or_replace_user, but it requires the path-supplied id and response-only etag. The generated create-user sample omits both, so consumers following it fail static type checking. Keep kind, nickname, and roleName required for input while making output-only properties non-required, then regenerate.
  • Files reviewed: 88/90 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.

Copilot AI review requested due to automatic review settings September 15, 2026 13:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Sync and async reverse-proxy routing can fail when either endpoint contains a trailing slash.

Review details

Files not reviewed (1)

  • sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/_patch.py:64

  • A trailing slash on either endpoint breaks reverse-proxy routing. PipelineClient normalizes the request URL to https://host/api/..., so an origin_endpoint stored as https://host/ no longer matches in ApiManagementProxy; a trailing slash on the proxy can also introduce //api/.... Normalize both endpoints before constructing the policies.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/aio/_patch.py:61
  • The async client has the same trailing-slash failure as the sync client: the normalized request URL may not match the stored origin, causing reverse_proxy_endpoint to be bypassed, or the replacement may create a double-slash path. Normalize both endpoint values before building the policies.
  • Files reviewed: 88/90 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.

Copilot AI review requested due to automatic review settings September 15, 2026 15:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Request TypedDicts incorrectly require response-only fields, preventing valid dictionary payloads from passing static type checking.

Get a fresh assessment by requesting another Copilot review.

Review details

Files not reviewed (1)

  • sdk/webpubsub/azure-messaging-webpubsubchatservice/package-lock.json: Generated file

Suppressed comments (3)

sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:80

  • id is supplied in the operation path and is read-only on ChatRoom, but this dict type requires callers to include it. This contradicts the generated create_or_replace_room sample, whose valid input contains only title; regenerate a writable input shape without response-only fields.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:101
  • userId is supplied in the operation path and is read-only on the response model, so requiring it here makes the dict overload reject the generated sample's valid { "roleName": ... } body. Generate a request-specific shape containing only writable fields.
    sdk/webpubsub/azure-messaging-webpubsubchatservice/azure/messaging/webpubsubchatservice/types.py:124
  • id is read-only on the user response model (models/_models.py:239) but is Required in the dict accepted by create_or_replace_user. Callers already pass the ID separately as user_id, so the dict overload cannot type-check a normal request; generate a writable user input shape instead.
  • Files reviewed: 88/90 changed files
  • Comments generated: 2
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.

:vartype etag: str
"""

id: Required[str]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the static-typing concern is valid. We are keeping the generated shape in this PR because the TypeSpec already marks these path/server-owned properties with @visibility(Lifecycle.Read), and the generated model constructors correctly exclude them from writable inputs. The mismatch is in the Python emitter's generated TypedDict surface, not the service contract.

This is not specific to Chat: azure-ai-contentunderstanding also accepts types.ContentAnalyzer in begin_create_analyzer, while that dictionary requires analyzerId, status, createdAt, and lastModifiedAt, all marked read-only on its model class. The relevant files are sdk/contentunderstanding/azure-ai-contentunderstanding/azure/ai/contentunderstanding/types.py and the corresponding models/_models.py and _operations/_operations.py.

Hand-editing types.py would be overwritten on regeneration; adding Chat-specific request models solely to compensate would introduce an API divergence without fixing the shared emitter behavior. We therefore prefer a shared emitter fix that respects input visibility, followed by regeneration, rather than changing the service models or generated shape in this PR.

The sync/async live tests use model instances such as ChatMessage(created_by=..., content=...), ChatRoom(title=...), and HumanChatUser(nickname=..., role_name=...). Those constructors and request serialization work without server-owned fields. Passing live tests does not resolve the dictionary typing issue: TypedDict requirements are not enforced at runtime. Model instances remain the supported typed path while this generator limitation remains.

:vartype etag: str
"""

name: Required[str]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that a permissions-only dictionary should not need the path-supplied role name or response ETag. The same applies to the room-member dictionary. We are keeping the generated shape in this PR for the shared-emitter reasons explained in #48882 (comment).

The TypeSpec already marks ChatRole.name, ChatRoomMember.userId, and the ETag fields as read-only. The generated model constructors correctly accept ChatRole(permissions=...) and ChatRoomMember(role_name=...), with the resource identifiers supplied separately as operation arguments; our live tests exercise those paths.

The remaining limitation is specifically the generated dictionary annotations. We prefer to address input visibility in the Python emitter and regenerate consistently across SDKs, rather than hand-edit generated types or introduce package-specific request models to work around it. This keeps generation reproducible and preserves the existing model-based API, while acknowledging that writable-only dictionaries still encounter static type-checking errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants